package com.qianbudai.koklinlearning.presenter

import android.text.TextUtils
import com.qianbudai.koklinlearning.model.UserModel
import com.qianbudai.koklinlearning.mvp.IPresenter

class UserPresenter(view: UserContract.IUserView):UserContract.IUserPresenter,
    IPresenter<UserContract.IUserView>(view) {

    override fun addUser(name: String) {

        //弹出对话框
        mView.get()?.showProgressDialog()

        //做一些校验
        if (!TextUtils.isEmpty(name)){
            UserModel.addUser(name) {
                //关闭对话框并显示结果
                mView.get()?.dismissProgressDialog()
                mView.get()?.showAddUserResult(it)
            }
        }
    }
}